package com.whfc.wxmp.api.uni.service.impl;

import com.whfc.common.result.PageData;
import com.whfc.common.util.DateUtil;
import com.whfc.entity.dto.OssPathDTO;
import com.whfc.uni.dto.CarInoutRecordDTO;
import com.whfc.uni.dto.CarLogDTO;
import com.whfc.uni.dto.CarStatisticalDTO;
import com.whfc.uni.service.CarInoutRecordService;
import com.whfc.wxmp.api.uni.service.MpCarInoutRecordService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @ClasssName MsCarInoutRecordServiceImpl
 * @Description 车辆管理
 * @Author hw
 * @Date 2020/12/15 11:36
 * @Version 1.0
 */
@Service
public class MpCarInoutRecordServiceImpl implements MpCarInoutRecordService {

    @DubboReference(interfaceClass = CarInoutRecordService.class, version = "1.0.0")
    private CarInoutRecordService carInoutRecordService;

    @Override
    public PageData<CarInoutRecordDTO> selectRecordList(Integer deptId, Date time, Integer pageNum, Integer pageSize) {
        Date startTime = DateUtil.getDateBegin(time);
        Date endTime = DateUtil.getDateEnd(time);
        return carInoutRecordService.getRecordList(deptId, startTime, endTime, pageNum, pageSize);
    }

    @Override
    public PageData<CarInoutRecordDTO> selectMontRecordList(Integer deptId, Date date, Integer pageNum, Integer pageSize) {
        Date startTime = DateUtil.getMonthBegin(date);
        Date endTime = DateUtil.getMonthEnd(date);
        return carInoutRecordService.getRecordList(deptId, startTime, endTime, pageNum, pageSize);
    }

    @Override
    public PageData<CarInoutRecordDTO> selectRecordList(Integer deptId, Date startTime, Date endTime, Integer pageNum, Integer pageSize) {
        return carInoutRecordService.getRecordList(deptId, startTime, endTime, pageNum, pageSize);
    }

    @Override
    public CarStatisticalDTO getDayStatistical(Integer deptId, Date time) {
        Date startTime = DateUtil.getDateBegin(time);
        Date endTime = DateUtil.getDateEnd(time);
        return carInoutRecordService.getDayStatistical(deptId, startTime, endTime);
    }

    @Override
    public CarStatisticalDTO getMonthStatistical(Integer deptId, Date date) {
        Date startTime = DateUtil.getMonthBegin(date);
        Date endTime = DateUtil.getMonthEnd(date);
        return getMonthStatistical(deptId, startTime, endTime);
    }

    @Override
    public CarStatisticalDTO getMonthStatistical(Integer deptId, Date startTime, Date endTime) {
        return carInoutRecordService.getMonthStatistical(deptId, startTime, endTime);
    }

    @Override
    public OssPathDTO export(Integer deptId, Date startTime, Date endTime) {
        return carInoutRecordService.export(deptId, startTime, endTime);
    }

    @Override
    public OssPathDTO export(Integer deptId, Date time) {
        Date startTime = DateUtil.getDateBegin(time);
        Date endTime = DateUtil.getDateEnd(time);
        return carInoutRecordService.export(deptId, startTime, endTime);
    }

    @Override
    public OssPathDTO montExport(Integer deptId, Date date) {
        Date startTime = DateUtil.getMonthBegin(date);
        Date endTime = DateUtil.getMonthEnd(date);
        return carInoutRecordService.export(deptId, startTime, endTime);
    }

    @Override
    public CarLogDTO carLog(Integer deptId, Date date) {
        return carInoutRecordService.carLog(deptId, date);
    }
}
